﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Web;
using Web.Helper;
using Microsoft.WindowsAzure;

namespace Web.Services
{
    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
    public class Operations : IOperations
    {
        private SaudoLogic logic;
        private string session;
        private string username;

        public Operations()
        {
            logic = new SaudoLogic();
        }

        #region Login Handling - please do better in real life

        public void Open(string session)
        {
            this.session = session;            
        }

        public void Login(string username, string password)
        {
            // TODO: AUth
            this.username = username;
        }

        public void Close()
        {
            this.session = string.Empty;
            this.username = string.Empty;
        }

        #endregion

        public string SendSaudo(string receiver, string text)
        {
            // TODO: Get current user
            return logic.SendSaudo("test", receiver, text).RowKey;
        }

        public void VoteSaudo(string key)
        {
            // TODO: Get current session
            logic.VoteSaudo(key);
        }

        public void CommentSaudo(string key, string text)
        {
            logic.CommentSaudo(key, text);
        }
    }
}
